﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Manage/MasterPage.master" AutoEventWireup="true" CodeFile="ListUsers.aspx.cs" Inherits="Manage_ListUsers" %>
<%@ Register Src="~/Manage/CmsMessageBox.ascx" TagPrefix="cms" TagName="MessageBox" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <script type="text/javascript">
        $(document).ready(function () {
            $('#SearchBar').width($('#Body table.List').width());
         
            $('#<%=DeleteUser.ClientID %>').click(function () {
                //判断chkID选中的个数
                if (Cms_CkeckedCount('chkID') == 0) {
                    Cms_MessageBox("请选择将要删除的用户。");
                    return false;
                } else {
                    return Cms_Confirm('确认删除当前选中的用户吗？');
                }
            });

            $('a[uid]').click(function () {
                if (confirm('你确认重置用户密码吗？')) {
                    var o = $(this);
                    $.ajax({
                        type: "POST",
                        url: "./ResetPassword.aspx",
                        data: "uid=" + o.attr("uid"),
                        success: function (msg) {
                            if (msg.indexOf("SUCCESS") != -1) {
                                alert('用户密码已经被重置，提示用户下次登录使用默认密码。');
                            } else if (msg.indexOf("ERROR") != -1) {
                                alert('发生错误，请稍后再试。');
                            }
                        },
                        error: function (msg) {
                            alert("发生错误: " + msg.responseText);
                        }
                    });
                }
            });
        });
    </script>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="body" Runat="Server">
    <cms:MessageBox id="MessageBox" runat="server" />
    <asp:HiddenField ID="CurrentPage" runat="server" Value="1" />
    <div id="SearchBar">
        <table cellpadding="0" cellspacing="0">
            <tr>
                <td>县区：</td>
                <td><asp:DropDownList ID="Districts" runat="server" Width="100px" 
                        AutoPostBack="True" onselectedindexchanged="Districts_SelectedIndexChanged"></asp:DropDownList></td>
                <td>&nbsp;&nbsp;&nbsp;&nbsp;单位：</td>
                <td><asp:DropDownList ID="Departments" runat="server" Width="150px" 
                        AutoPostBack="True" onselectedindexchanged="Departments_SelectedIndexChanged"></asp:DropDownList></td>
                <td><asp:HyperLink ID="AddUser" runat="server" NavigateUrl="~/Manage/EditUser.aspx" SkinID="AddLink">增加用户</asp:HyperLink></td>
                <td><asp:LinkButton ID="DeleteUser" runat="server" Text="删除用户" 
                        SkinID="DeleteButton" onclick="DeleteUser_Click"></asp:LinkButton></td>
                <td><asp:TextBox ID="SearchCondition" runat="server" SkinID="SearchBox" /><asp:HiddenField ID="SearchConditionHidden" runat="server" /></td>
                <td><asp:Button ID="Search" runat="server" Text="查询" onclick="Search_Click"/></td>
            </tr>
        </table>
    </div>
    <div style="clear: both">
        <asp:Repeater ID="UsersView" runat="server">
            <HeaderTemplate>
                <table class="List" cellspacing="1">
                    <tr class="header">
                        <th style="width:50px">操作</th>
                        <th style="width:80px">用户名</th>
                        <th style="width:150px">姓名</th>
                        <th style="width:100px">所在县区</th>
                        <th style="width:250px">隶属部门</th>
                        <th style="width:200px">权限</th>
                        <th style="width:80px">&nbsp;</th>
                    </tr>
            </HeaderTemplate>
            <AlternatingItemTemplate>
                <tr class="even">
                    <td align="center" style="width:50px;">
                        <input type="checkbox" name="chkID" value='<%#Eval("ID") %>' />
                    </td>
                    <td align="center" style="width:80px;">
                        <asp:HyperLink ID="EditTopic" runat="server" 
                            NavigateUrl='<%#"~/Manage/EditUser.aspx?uid=" + Eval("ID") %>'><%#Eval("ID") %></asp:HyperLink>    
                    </td>
                    <td align="center" style="width:150px;"><%#Eval("Name") %></td>
                    <td align="center" style="width:100px;"><%#Eval("District") %></td>
                    <td align="center" style="width:250px;"><%#Eval("Belong") %></td>
                    <td align="center" style="width:200px;">
                        <%#Eval("Power")%>
                    </td>
                    <td align="center" style="width: 80px">
                        <a href="javascript:void(0);" uid='<%#Eval("ID") %>'>重置密码</a>
                    </td>
                </tr>
            </AlternatingItemTemplate>
            <ItemTemplate>
                <tr class="odd">
                    <td align="center" style="width:50px;">
                        <input type="checkbox" name="chkID" value='<%#Eval("ID") %>' />
                    </td>
                    <td align="center" style="width:80px;">
                        <asp:HyperLink ID="EditTopic" runat="server" 
                            NavigateUrl='<%#"~/Manage/EditUser.aspx?uid=" + Eval("ID") %>'><%#Eval("ID")%></asp:HyperLink>    
                    </td>
                    <td align="center" style="width:150px;"><%#Eval("Name") %></td>
                    <td align="center" style="width:100px;"><%#Eval("District") %></td>
                    <td align="center" style="width:250px;"><%#Eval("Belong") %></td>
                    <td align="center" style="width:200px;">
                        <%#Eval("Power")%>
                    </td>
                    <td align="center" style="width: 80px">
                        <a href="javascript:void(0);" uid='<%#Eval("ID") %>'>重置密码</a>
                    </td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                <tr class="Footer">
                    <td colspan="7" align="center" valign="middle">
                        <table cellpadding="0" cellspacing="0">
                            <tr>
                                <td>共 <%=pds.DataSourceCount %> 条记录</td>
                                <td><asp:LinkButton ID="FirstButton" runat="server" SkinID="FirstButton" OnCommand="ChangePage" CommandArgument="F">&nbsp;</asp:LinkButton></td>
                                <td><asp:LinkButton ID="PreviousButton" runat="server" SkinID="PreviousButton" OnCommand="ChangePage" CommandArgument="P">&nbsp;</asp:LinkButton></td>
                                <td>第 <%=pds.CurrentPageIndex+1 %> 页 / 共 <%=pds.PageCount %> 页</td>
                                <td><asp:LinkButton ID="NextButton" runat="server" SkinID="NextButton" OnCommand="ChangePage" CommandArgument="N">&nbsp;</asp:LinkButton></td>
                                <td><asp:LinkButton ID="LastButton" runat="server" SkinID="LastButton" OnCommand="ChangePage" CommandArgument="L">&nbsp;</asp:LinkButton></td>
                                <td><asp:TextBox ID="GotoPage" runat="server" Width="30px"></asp:TextBox></td>
                                <td><asp:LinkButton ID="GotoButton" runat="server" SkinID="GotoButton" OnCommand="ChangePage" CommandArgument="G">&nbsp;</asp:LinkButton></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                </table>
            </FooterTemplate>
        </asp:Repeater>
    </div>
</asp:Content>